package org.xdj.blue.dubbo.tools;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Utill {

	private static ObjectMapper objectMapper = new ObjectMapper();
	
	public static String toJson(Object obj){
		String value ="";
		try {
			value =objectMapper.writeValueAsString(obj);
		} catch (JsonProcessingException e) {
			
			e.printStackTrace();
		}
		return value;
	}
	
	public static <T> T fromJson(String json,Class<T> clazz){
		try {
			return objectMapper.readValue(json, clazz);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
